include(FetchContent)
FetchContent_Declare(
    googletest
    GIT_REPOSITORY https://gitee.com/openharmony/third_party_googletest.git
    GIT_TAG OpenHarmony-v3.2.2-Release
)

FetchContent_Declare(
    bounds_checking_function
    GIT_REPOSITORY https://gitee.com/openharmony/third_party_bounds_checking_function.git
    GIT_TAG OpenHarmony-v3.2-Release
)

FetchContent_MakeAvailable(googletest bounds_checking_function)

set(SECUREC_DIR ${bounds_checking_function_SOURCE_DIR})
set(SECUREC_SRC ${SECUREC_DIR}/src)
set(SECUREC_INC ${SECUREC_DIR}/include)

add_library(
    securec OBJECT
    ${SECUREC_SRC}/memcpy_s.c
    ${SECUREC_SRC}/memset_s.c
    ${SECUREC_SRC}/memmove_s.c
    ${SECUREC_SRC}/securecutil.c
    ${SECUREC_SRC}/secureprintoutput_a.c
    ${SECUREC_SRC}/snprintf_s.c
    ${SECUREC_SRC}/sprintf_s.c
    ${SECUREC_SRC}/strcpy_s.c
    ${SECUREC_SRC}/strtok_s.c
    ${SECUREC_SRC}/vsnprintf_s.c
    ${SECUREC_SRC}/vsprintf_s.c
)
target_include_directories(securec PUBLIC ${SECUREC_INC})
target_include_directories(securec PRIVATE ${SE_BASE_SERVICES_DEFAULT_INC})
target_compile_options(securec PRIVATE ${SE_BASE_SERVICES_DEFAULT_CC})

add_library(securec_interface INTERFACE)
target_include_directories(securec_interface INTERFACE ${SECUREC_INC})

option(
    OPTION_SECUREC_INDEPENDENT
    "use independent secure c"
    ON
)
